package com.knowif.dto;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.knowif.pojo.TutorEducationInfo;
import com.knowif.pojo.UserItem;

public class CategoryDto {
	
	private Integer enterpriseType;
	private Integer id;
	private Integer tutorEducationInfoId;
	private Integer itemId;
	private Integer languageType;
	private Integer userId;
	 /**
     * 导师id
     */
    private Integer tutorId;

    /**
     * 省份id
     */
    private Integer provinceId;

    private String provinceName;

    /**
     * 城市id
     */
    private Integer cityId;

    /**
     * 城市名
     */
    private String cityName;

    private Integer schoolId;

    private String schoolName;

    /**
     * 专业id
     */
    private Integer specialId;

    /**
     * 专业名称
     */
    private String specialName;

    /**
     * 学历等级id 1本2硕3博4硕博连读5博士后
     */
    private Integer eduLevelId;

    /**
     * 学历等级名称 1专2本3硕4博
     */
    private String eduLevelName;

    /**
     * 区域id
     */
    private Integer continentId;

    /**
     * 区域名称
     */
    private String continentName;

	/**
	 * 国家id
	 */
	private Integer countryId;

	/**
	 * 国家名称
	 */
	private String countryName;

    private Integer userItemId;
	public Integer getEduLevelId() {
		return eduLevelId;
	}
	public void setEduLevelId(Integer eduLevelId) {
		this.eduLevelId = eduLevelId;
	}
	
	public Integer getEnterpriseType() {
		return enterpriseType;
	}
	public void setEnterpriseType(Integer enterpriseType) {
		this.enterpriseType = enterpriseType;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getItemId() {
		return itemId;
	}
	public void setItemId(Integer itemId) {
		this.itemId = itemId;
	}
	public Integer getLanguageType() {
		return languageType;
	}
	public void setLanguageType(Integer languageType) {
		this.languageType = languageType;
	}
	public Integer getProvinceId() {
		return provinceId;
	}
	public void setProvinceId(Integer provinceId) {
		this.provinceId = provinceId;
	}
	public Integer getSchoolId() {
		return schoolId;
	}
	public void setSchoolId(Integer schoolId) {
		this.schoolId = schoolId;
	}
	public Integer getSpecialId() {
		return specialId;
	}
	public void setSpecialId(Integer specialId) {
		this.specialId = specialId;
	}
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	public Integer getTutorId() {
		return tutorId;
	}
	public void setTutorId(Integer tutorId) {
		this.tutorId = tutorId;
	}
	public String getProvinceName() {
		return provinceName;
	}
	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	public Integer getCityId() {
		return cityId;
	}
	public void setCityId(Integer cityId) {
		this.cityId = cityId;
	}
	public String getCityName() {
		return cityName;
	}
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	public String getSchoolName() {
		return schoolName;
	}
	public void setSchoolName(String schoolName) {
		this.schoolName = schoolName;
	}
	public String getSpecialName() {
		return specialName;
	}
	public void setSpecialName(String specialName) {
		this.specialName = specialName;
	}
	public String getEduLevelName() {
		return eduLevelName;
	}
	public void setEduLevelName(String eduLevelName) {
		this.eduLevelName = eduLevelName;
	}
	public Integer getContinentId() {
		return continentId;
	}
	public void setContinentId(Integer continentId) {
		this.continentId = continentId;
	}
	public String getContinentName() {
		return continentName;
	}
	public void setContinentName(String continentName) {
		this.continentName = continentName;
	}
	public Integer getUserItemId() {
		return userItemId;
	}
	public void setUserItemId(Integer userItemId) {
		this.userItemId = userItemId;
	}
	public Integer getTutorEducationInfoId() {
		return tutorEducationInfoId;
	}
	public void setTutorEducationInfoId(Integer tutorEducationInfoId) {
		this.tutorEducationInfoId = tutorEducationInfoId;
	}
	public Integer getCountryId() {
		return countryId;
	}
	public void setCountryId(Integer countryId) {
		this.countryId = countryId;
	}
	public String getCountryName() {
		return countryName;
	}
	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}

	@Override
	public String toString() {
		return "CategoryDto [eduLevelId=" + eduLevelId + ", enterpriseType=" + enterpriseType + ", id=" + id
				+ ", itemId=" + itemId + ", languageType=" + languageType + ", provinceId=" + provinceId + ", schoolId="
				+ schoolId + ", specialId=" + specialId + ", userId=" + userId + "]";
	}
	public static List<UserItem> change2UserItems(List<CategoryDto> categoryDtos){
		if(categoryDtos == null || categoryDtos.isEmpty()){
			return null;
		}
		List<UserItem> userItems = new ArrayList<UserItem>();
		UserItem userItem = null;
		for(CategoryDto categoryDto : categoryDtos){
			userItem = new UserItem();
			BeanUtils.copyProperties(categoryDto, userItem);
			
			userItem.setTutorEducationInfo(change2TutorEducationInfo(categoryDto));
			userItems.add(userItem);
		}
		return userItems;
	}
	
	
	private static TutorEducationInfo change2TutorEducationInfo(CategoryDto categoryDto){
		if(categoryDto == null){
			return null;
		}
		TutorEducationInfo tutorEducationInfo = new TutorEducationInfo();
		BeanUtils.copyProperties(categoryDto, tutorEducationInfo);
		tutorEducationInfo.setId(categoryDto.getTutorEducationInfoId());
		return tutorEducationInfo;
	}
	
	
	public static List<CategoryDto> userItems2CategoryDto(List<UserItem> userItems){
		if(userItems == null || userItems.isEmpty()){
			return null;
		}
		List<CategoryDto> categoryDtos = new ArrayList<CategoryDto>();
		CategoryDto categoryDto = null;
		for(UserItem userItem : userItems){
			categoryDto = new CategoryDto();
			BeanUtils.copyProperties(userItem, categoryDto);
			int id = userItem.getId();
			if(userItem.getTutorEducationInfo() != null){
				BeanUtils.copyProperties(userItem.getTutorEducationInfo(), categoryDto);
				categoryDto.setId(id);
				categoryDto.setTutorEducationInfoId(userItem.getTutorEducationInfo().getId());
			}
			categoryDtos.add(categoryDto);
		}
		return categoryDtos;
	}
}

















